import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

// 导入 Reg 、  Login  
import Reg from '@/views/Reg/Reg.vue'
import Login from '@/views/Login/Login.vue'
import Main  from '@/views/Main/Main.vue'
import Home from '@/views/Menus/Home/Home.vue'
// src/router/index.js 路由模块

// // 把下面的代码粘贴到路由模块中对应的位置，即可防止路由报错的问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


// 配置路由规则
const routes = [
      {
        path:'/reg',component:Reg 
      },
      { 
        path:'/login',component:Login
      },
      {
        path:'/',component:Main,
        // 重定向
        redirect: '/home',
        children:[
          { path:'home',component:Home }
        ]
      }
]

const router = new VueRouter({
  routes
})

export default router
